var api = require('../../util/api.js');
Page({
  data: {

  },
  onLoad: function (options) {
    this.setData({
      examineName: api.chain().examineName,
      wx0501: api.hasPerm('lhjd:wx:05:01'),
      wx0502: api.hasPerm('lhjd:wx:05:02'),
      wx0503: api.hasPerm('lhjd:wx:05:03'),
      wx0504: api.hasPerm('lhjd:wx:05:04')
    })
  },
  //总成绩排名
  showTotalRanking: function () {
    wx.navigateTo({
      url: `./ranking-data/ranking-data`
    });
  },
  //各项成绩排名
  showItemAvgRanking: function (t) {
    wx.navigateTo({
      url: `./ranking-item/ranking-item`
    });
  },
  //详细成绩
  showDetail: function () {
    wx.navigateTo({
      url: `./data-detail/data-detail`
    });
  },
  //导出数据
  export () {
    // wx.showLoading({
    //   title: '正在下载',
    //   icon: 'loading'
    // });
    // wx.downloadFile({
    //   url: `${api.ip}lhjd/total/exportAll?examineId=${api.chain().examineId}`,
    //   header: {
    //     'content-type': 'application/x-www-form-urlencoded',
    //     'Authorization': wx.getStorageSync('token')
    //   },
    //   success: res => {
    //     wx.hideLoading();
    //     console.log(res)
    //   }
    // })

    // var _this = this;
    // wx.setClipboardData({
    //   data: `${api.ip}lhjd/total/exportAll?examineId=${api.chain().examineId}`,
    //   success: function (res) {
    //     // wx.showToast({
    //     //   title: '下载地址已经复制到剪切板',
    //     // });
    //   }
    // });

    // var _this = this;
    let token = wx.getStorageSync('token');
    let url = `${api.ip}lhjd/total/exportAll?examineId=${api.chain().examineId}&Authorization=${token}`;
    wx.showModal({
      title: '下载地址',
      content: url,
      confirmText: '复制',
      success: function (res) {
        if (res.confirm) {
          wx.setClipboardData({
            data: url
          });
        }
      }
    })
  }
})